<template>
	<view class="dialog" @click.stop="clkclose" :style="{ 'height': setHeight + 'px' }">
		<view @click.stop="clknone" class="dlgcon" style="width: 300px;">
			<view class="comtitle"></view>
			<form class="formlist" @submit="save">
				<view class="ln"><input name="amount" :value="amount" placeholder="输入付款金额" /></view>
				<picker mode="date" :value="tm" @change="seltm">
					<view class="ln">{{tm}}</view>
				</picker>
				<view class="ln"><input name="bz" :value="bz" placeholder="输入备注" /></view>
				<button form-type="submit">保存</button>	
			</form>	
		</view>
	</view>
</template>

<script>
	export default {
		name:"fkedit",
		props:['kpid','fkid'],
		data() {
			return {
				setHeight:200,
				amount:'',
				tm:'输入付款时间',
				bz:''
			};
		},
		mounted(){
			//console.log("fkedit",this.kpid);
			if(this.fkid > 0){
				this.ld();
			}
			let self = this;
			uni.getSystemInfo({
			    success: function (res) {
					self.setHeight = res.screenHeight;
			        //console.log("show getSystemInfo",res);
			    }
			});
		},
		methods:{
			ld(){
				let self = this;
				uni.request({
					url:this.apibase + "fkdetail?fkid=" + this.fkid,
					success: (res) => {
						self.amount = (res.data.amount|0)/100;
						self.tm = res.data.tm||'';
						self.bz = res.data.bz||'';
					}
				});
			},
			save(e){
				let self = this, pd = e.detail.value;
				pd.kpid = this.kpid;
				pd.tm = this.tm;
				uni.request({
					url:this.apibase + (this.id?"fkedit?fkid="+this.fkid:"fkadd"),
					method:"POST",
					data:pd,
					success: (res) => {
						uni.showToast({
							title:"操作成功"
						})
						self.$emit("close");
						//console.log(res.data);
					}
				});
			},
			seltm(e){
				this.tm = e.detail.value;
			},
			clkclose(){
				console.log('clkclose');
				this.$emit("close");
			},
			clknone(e){
				console.log('clknone');
			}
		}
	}
</script>

<style>

</style>
